package com.atguigu.springcloud.callback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;

//通过实现 ConfirmCallback 接口，消息发送到 Broker 后触发回调，确认消息是否到达 Broker 服务器，也就是只确认是否正确到达 Exchange中
public class RabbitMQConfirmCallback implements ConfirmCallback {

	private static final Logger log = LoggerFactory.getLogger(RabbitMQConfirmCallback.class.getSimpleName());

	@Override
	public void confirm(CorrelationData correlationData, boolean ack, String cause) {
		
		log.info("收到RabbitMQConfirmCallback回调");
		log.debug("correlationData.id->" + correlationData.getId());
		log.debug("correlationData.returnedMessage->" + correlationData.getReturnedMessage().toString());
		log.debug("ack->" + String.valueOf(ack));
		log.debug("cause->" + cause);
	}
}
